<template>
    <div :loading="listLoading">
        <div v-if="!ansewrDetail">
            <h2 style="margin-left: 15px;font-size:24px">
                {{ paperInfo }}(总分{{ paper.fullMarks }}
                <span v-if="!isOperation" style="color: red">/得分{{ score }}</span>)
            </h2>
            <div style="height: calc(100vh - 200px); overflow-y: scroll;">
                <Card v-if="radioShow" dis-hover style="margin: 10px 15px">
                    <p slot="title" style="color:blue">
                        单选题（{{paper.paperRadioNum}}分/题）
                    </p>
                    <span  slot="extra" style="font-size:16px;color:blue">
                        共{{paper.radio !== undefined && paper.radio !== null && paper.radio.length > 0 ? paper.radio.length : ""}}道
                    </span>
                    <List>
                        <ListItem v-for="(item, index) in radioData" :key="index"
                                :style="{backgroundImage: 'url('+ item.imgPath+ ')',backgroundRepeat: 'no-repeat',backgroundSize: '13% 100%', backgroundPosition: 'right top'}">
                            <div>
                                <p class="problem_item">
                                    <span>{{ index + 1 }}、</span>
                                    {{ item.subject }}
                                </p>
                                <RadioGroup v-model="item.checked" :disabled="!isOperation" vertical>
                                    <p class="checkbox_item" :label="index2" v-for="(aw, index2) in item.questionDetailList" v-bind:key="index2">
                                        <Radio :label="aw.questionDetailId">
                                            <span>{{aw.answerOption}}</span>
                                        </Radio>
                                    </p>
                                </RadioGroup>
                                <ShowAnswer v-if="!isOperation" :answer="item" />
                                <Divider v-if="index < paper.paperRadio - 1" v-show="index < paper.paperRadio - 1" />
                            </div>
                        </ListItem>
                    </List>
                </Card>
                <Card v-if="checkboxShow" dis-hover style="margin: 10px 15px">
                    <p slot="title" style="color:blue">
                        多选题（{{paper.paperCheckboxNum}}分/题）
                    </p>
                    <span slot="extra" style="font-size:16px;color:blue">
                        共{{paper.checkbox !== undefined && paper.checkbox !== null && paper.checkbox.length > 0 ? paper.checkbox.length : ""}}道
                    </span>
                    <List>
                        <ListItem v-for="(item, index) in checkboxData" v-bind:key="index"
                                  :style="{backgroundImage: 'url(' + item.imgPath + ')', backgroundRepeat: 'no-repeat', backgroundSize: '13% 100%', backgroundPosition: 'right top'}">
                            <div>
                                <p class="problem_item"><span>{{index+1}}、</span>{{item.subject}}</p>
                                <CheckboxGroup v-model="item.checked" vertical :disabled="!isOperation">
                                    <p class="checkbox_item" :label="index2" v-for="(aw, index2) in item.questionDetailList" v-bind:key="index2">
                                        <Checkbox :label="aw.questionDetailId">
                                            <span>{{aw.answerOption}}</span>
                                        </Checkbox>
                                    </p>
                                </CheckboxGroup>
                                <ShowAnswer v-if="!isOperation" :answer="item" />
                                <Divider v-if="index < paper.paperCheckbox - 1" v-show="index < paper.paperCheckbox - 1" />
                            </div>
                        </ListItem>
                    </List>
                </Card>
                <Card v-if="judgeShow" dis-hover style="margin: 10px 15px">
                    <p slot="title" style="color:blue">
                        判断题（{{paper.paperJudgeNum}}分/题）
                    </p>
                    <span slot="extra" style="font-size:16px;color:blue">
                        共{{paper.judge !== undefined && paper.judge !== null && paper.judge.length > 0 ? paper.judge.length : ""}}道
                    </span>
                    <List>
                        <ListItem v-for="(item, index) in judgeData" v-bind:key="index"
                                  :style="{backgroundImage: 'url(' + item.imgPath + ')', backgroundRepeat: 'no-repeat', backgroundSize: '13% 100%', backgroundPosition: 'right top'}">
                            <div>
                                <p class="problem_item"><span>{{index+1}}、</span>{{item.subject}}</p>
                                <RadioGroup v-model="item.checked" vertical :disabled="!isOperation">
                                    <p class="checkbox_item" :label="index2" v-for="(aw, index2) in item.questionDetailList" v-bind:key="index2">
                                        <Radio :label="aw.questionDetailId">
                                            <span>{{aw.answerOption}}</span>
                                        </Radio>
                                    </p>
                                </RadioGroup>
                                <ShowAnswer v-if="!isOperation" :answer="item" />
                                <Divider v-if="index < paper.paperJudge - 1" v-show="index < paper.paperJudge - 1" />
                            </div>
                        </ListItem>
                    </List>
                </Card>
                <!--<BackTop :height="100" :bottom="100"><div class="top">返回顶端</div></BackTop>-->
                <BackTop :height="100" :bottom="100">
                    <div style="height: 100%;width: 100%;background-color: #f2f5f6;box-shadow: 0 0 6px rgba(0,0,0, .12);text-align: center;line-height: 40px;color: #1989fa;">TOP</div>
                </BackTop>
            </div>
            <div style="height: 20px;margin-top: 10px;">
                <Row v-if="isOperation">
                    <Col span="16">
                        <label style="font-size: 14px;color: #6D6D6D;font-weight: bold;margin-left: 2%;">
                            答题开始时间：{{ beginTime }}&emsp;&emsp;&emsp;&emsp; 已用时:{{ useMin }}分{{
                            useSec
                            }}秒&emsp;&emsp;&emsp;&emsp; 剩余时间：{{ min }}分{{ sec }}秒
                        </label>
                    </Col>
                    <Col span="8">
                        <div style="text-align: right;margin-right: 15px;">
                            <Button style="margin-right: 10px" type="primary" @click="submit">交卷</Button>
                            <Button @click="giveUpAnswer">放弃答题</Button>
                        </div>
                    </Col>
                </Row>
                <Row v-else>
                    <Col span="24">
                        <div style="text-align: center">
                            <Button @click="goback">退出</Button>
                        </div>
                    </Col>
                </Row>
            </div>
        </div>

        <Card v-else dis-hover style="margin: 10px 15px">
            <div style="text-align:center;" :style="{ height: divHeight + 'px', verticalAlign: 'middle' }">
                <h3>
                    提交成功
                    <br />
                    得分 {{ paperResult }}
                </h3>
                <Divider />
                <div style="text-align: center">
                    <Button type="success" style="width: 10%" @click="goback">返回</Button>
                </div>
            </div>
        </Card>
    </div>
</template>

<script>

    import ShowAnswer from './showAnswer'
    import timg from './timg.png'
    import timg2 from './timg2.jpg'
    import {sessionStorage, cookie} from '@/common/cacheUtils.js';
    import {Api} from '@/api/index.js'
    import {formatDate,convertDateTime,computeIntervalMin} from '@/tools/index'

    export default {
        components: { ShowAnswer },
        props: {
            isOperation: {
                type: Boolean,
                default() {
                    return false;
                }
            }
        },
        data(){
            return{
                beginTime: formatDate(new Date(),'yyyy-MM-dd hh:mm:ss'),
                min: "00",
                sec: "00",
                uses1: 0,
                useSec: "00",
                useMin: "00",
                listLoading: false,
                paperInfo: "",
                paperId: "",
                paperResultId: "",
                examDuration: 0,
                paper: {},

                styleObject: "correct",
                img: timg,
                img2: timg2,

                radioData: [],
                checkboxData: [],
                judgeData: [],
                radioShow: true,
                checkboxShow: true,
                judgeShow: true,
                totalScore: 0,
                score: 0,
                divHeight: 0,
                ansewrDetail: false,
                paperResult: ""
            }
        },
        mounted() {
            this.divHeight = window.innerHeight * 0.78;
            this.paperInfo = this.$attrs.paper.paperInfo;
            this.paperId = this.$attrs.paper.paperId;
            this.paperResultId = this.$attrs.paper.paperResultId;
            this.score = this.$attrs.paper.paperResult;
            this.examDuration = this.$attrs.paper.examDuration;
            if (this.isOperation) {
                this.query();
            } else {
                this.getPaperResult();
            }
            if (this.isOperation) {
                this.$http.get(Api.paper +'/getExamTime/'+this.paperResultId+'/1').then(res => {
                    if (res.code === 200 && res.data.data) {
                        let examTime = convertDateTime(res.data.data);
                        let intervalMin = computeIntervalMin(examTime, new Date(), false);
                        if (intervalMin < this.examDuration) {
                            this.examDuration -= intervalMin;
                        }
                    }
                    this.countDown();
                });
            }
        },
        methods: {
            // 倒计时
            countDown() {
                const m1 = this.examDuration * 60;
                const msec = m1 - this.uses1;
                if (msec < 1) {
                    this.autoSubmit();
                    return;
                }
                const min = parseInt(msec / 60);
                const sec = parseInt(msec % 60);
                this.min = min > 9 ? min : "0" + min;
                this.sec = sec > 9 ? sec : "0" + sec;
                const useM = parseInt(this.uses1 / 60);
                const useS = parseInt(this.uses1 % 60);
                this.useMin = useM > 9 ? useM : "0" + useM;
                this.useSec = useS > 9 ? useS : "0" + useS;
                let _that = this;
                this.uses1++;
                if (min >= 0 && sec >= 0) {
                    // 倒计时结束
                    if (min === 0 && sec === 0) {
                        return;
                    }
                    setTimeout(function() {
                        _that.countDown();
                    }, 1000);
                }
            },
            // 放弃答题
            giveUpAnswer() {
                this.$Modal.confirm({
                    title: '提示',
                    content: '<p>是否放弃此次答题？</p>',
                    okText: '确认',
                    onOk: () => {
                        this.giveAnswer()
                    }
                })
            },
            // 非正常放弃答题
            giveAnswer() {
                this.$http.post(Api.paper+'/giveUpAnswerPaper/'+this.paperResultId, {}).then(res => {
                    if (res.data.data == true) {
                        this.$emit("closeAnswer", false);
                    } else {
                        this.$Message.error(res.data.msg);
                    }
                }).catch(e => {
                    debugger
                    this.$emit("closeAnswer", false);
                });
            },
            query(){
                this.listLoading = true;
                this.radioData = [];
                this.checkboxData = [];
                this.judgeData = [];
                this.$http.get(Api.paper +'/toAnswerPaper/'+this.paperId).then(res => {
                    this.paper = res.data.data;
                    if (res.data.data.radio) {
                        const radioData = res.data.data.radio;
                        for (let i = 0; i < radioData.length; i++) {
                            const ckeck = radioData[i].checkId !== null && radioData[i].checkId !== "" && radioData[i].checkId !== undefined ? radioData[i].checkId : "";
                            let imgPath = "";
                            if (radioData[i].questionResult !== undefined && radioData[i].questionResult !== ""&& radioData[i].questionResult !== null) {
                                if (radioData[i].questionResult === "1") {
                                    // imgPath = this.img;
                                } else {
                                    // imgPath = this.img2;
                                }
                            }
                            const radio = {
                                subject: radioData[i].questionInfo,
                                checked: ckeck,
                                questionId: radioData[i].questionId,
                                imgPath: imgPath
                            };
                            const questionDetailList = radioData[i]["questionDetailList"];
                            for (let j = 0; j < questionDetailList.length; j++) {
                                const questionDetail = questionDetailList[j];
                                if (questionDetail.correctOption === "1") {
                                    radio["answer"] = questionDetail.questionDetailId;
                                }
                            }
                            radio["questionDetailList"] = questionDetailList;
                            this.radioData.push(radio);
                        }
                    }
                    if (this.radioData.length === 0) {
                        this.radioShow = false;
                    }
                    if (res.data.data.checkbox) {
                        const checkboxData = res.data.data.checkbox;
                        for (let i = 0; i < checkboxData.length; i++) {
                            let check = [];
                            if (checkboxData[i].checkId !== null && checkboxData[i].checkId !== "" && checkboxData[i].checkId !== undefined) {
                                check = checkboxData[i].checkId.split(",");
                            }
                            let imgPath = "";
                            if (checkboxData[i].questionResult !== undefined && checkboxData[i].questionResult !== ""&& checkboxData[i].questionResult !== null) {
                                if (checkboxData[i].questionResult === "1") {
                                    // imgPath = this.img;
                                } else {
                                    // imgPath = this.img2;
                                }
                            }
                            const checkbox = {
                                subject: checkboxData[i].questionInfo,
                                checked: check,
                                questionId: checkboxData[i].questionId,
                                imgPath: imgPath
                            };
                            const questionDetailList = checkboxData[i]["questionDetailList"];
                            const answerArray = [];
                            for (let j = 0; j < questionDetailList.length; j++) {
                                const questionDetail = questionDetailList[j];
                                if (questionDetail.correctOption === "1") {
                                    answerArray.push(questionDetail.questionDetailId);
                                }
                            }
                            checkbox["answer"] = answerArray;
                            checkbox["questionDetailList"] = questionDetailList;
                            this.checkboxData.push(checkbox);
                        }
                    }
                    if (this.checkboxData.length === 0) {
                        this.checkboxShow = false;
                    }
                    if (res.data.data.judge) {
                        const judgeData = res.data.data.judge;
                        for (let i = 0; i < judgeData.length; i++) {
                            let imgPath = "";
                            if (judgeData[i].questionResult !== undefined && judgeData[i].questionResult !== "" && judgeData[i].questionResult !== null) {
                                if (judgeData[i].questionResult === "1") {
                                    // imgPath = this.img;
                                } else {
                                    // imgPath = this.img2;
                                }
                            }
                            const ckeck = judgeData[i].checkId !== null && judgeData[i].checkId !== "" && judgeData[i].checkId !== undefined ? judgeData[i].checkId : "";
                            const judge = {
                                subject: judgeData[i].questionInfo,
                                checked: ckeck,
                                questionId: judgeData[i].questionId,
                                imgPath: imgPath
                            };
                            const questionDetailList = judgeData[i]["questionDetailList"];
                            for (let j = 0; j < questionDetailList.length; j++) {
                                const questionDetail = questionDetailList[j];
                                if (questionDetail.correctOption === "1") {
                                    judge["answer"] = questionDetail.questionDetailId;
                                }
                            }
                            judge["questionDetailList"] = questionDetailList;
                            this.judgeData.push(judge);
                        }
                    }
                    if (this.judgeData.length === 0) {
                        this.judgeShow = false;
                    }
                    this.listLoading = false;
                }).catch(e => {
                    this.listLoading = false;
                    this.$Message.error("获取试题失败");
                });
            },
            // 查看试卷
            getPaperResult() {
                this.listLoading = true;
                this.radioData = [];
                this.checkboxData = [];
                this.judgeData = [];
                this.$http.get(Api.paper +'/viewPaperResult/'+this.paperId+'/'+this.paperResultId).then(res => {
                        if (res.data.data) {
                            this.paper = res.data.data;
                            if (res.data.data.radio) {
                                const radioData = res.data.data.radio;
                                for (let i = 0; i < radioData.length; i++) {
                                    const ckeck = radioData[i].checkId !== null && radioData[i].checkId !== "" && radioData[i].checkId !== undefined ? radioData[i].checkId : "";
                                    let imgPath = "";
                                    if (radioData[i].questionResult !== undefined && radioData[i].questionResult !== "" && radioData[i].questionResult !== null) {
                                        if (radioData[i].questionResult === "1") {
                                            // imgPath = this.img;
                                        } else {
                                            // imgPath = this.img2;
                                        }
                                    }
                                    const radio = {
                                        questionResult: radioData[i].questionResult,
                                        subject: radioData[i].questionInfo,
                                        checked: ckeck,
                                        questionId: radioData[i].questionId,
                                        imgPath: imgPath
                                    };
                                    const questionDetailList = radioData[i]["questionDetailList"];
                                    for (let j = 0; j < questionDetailList.length; j++) {
                                        const questionDetail = questionDetailList[j];
                                        if (questionDetail.correctOption === "1") {
                                            radio["answer"] = questionDetail.questionDetailId;
                                        }
                                    }
                                    radio["questionDetailList"] = questionDetailList;
                                    this.radioData.push(radio);
                                }
                            }
                            if (this.radioData.length === 0) {
                                this.radioShow = false;
                            }
                            if (res.data.data.checkbox) {
                                const checkboxData = res.data.data.checkbox;
                                for (let i = 0; i < checkboxData.length; i++) {
                                    let check = [];
                                    if (checkboxData[i].checkId !== "" && checkboxData[i].checkId !== undefined && checkboxData[i].checkId !== null) {
                                        check = checkboxData[i].checkId.split(",");
                                    }
                                    let imgPath = "";
                                    if (checkboxData[i].questionResult !== undefined && checkboxData[i].questionResult !== "" && checkboxData[i].questionResult !== null) {
                                        if (checkboxData[i].questionResult === "1") {
                                            // imgPath = this.img;
                                        } else {
                                            // imgPath = this.img2;
                                        }
                                    }
                                    const checkbox = {
                                        questionResult: checkboxData[i].questionResult,
                                        subject: checkboxData[i].questionInfo,
                                        checked: check,
                                        questionId: checkboxData[i].questionId,
                                        imgPath: imgPath
                                    };
                                    const questionDetailList = checkboxData[i]["questionDetailList"];
                                    const answerArray = [];
                                    for (let j = 0; j < questionDetailList.length; j++) {
                                        const questionDetail = questionDetailList[j];
                                        if (questionDetail.correctOption === "1") {
                                            answerArray.push(questionDetail.questionDetailId);
                                        }
                                    }
                                    checkbox["answer"] = answerArray;
                                    checkbox["questionDetailList"] = questionDetailList;
                                    this.checkboxData.push(checkbox);
                                }
                            }
                            if (this.checkboxData.length === 0) {
                                this.checkboxShow = false;
                            }
                            if (res.data.data.judge) {
                                const judgeData = res.data.data.judge;
                                for (let i = 0; i < judgeData.length; i++) {
                                    let imgPath = "";
                                    if (judgeData[i].questionResult !== undefined && judgeData[i].questionResult !== "" && judgeData[i].questionResult !== null) {
                                        if (judgeData[i].questionResult === "1") {
                                            // imgPath = this.img;
                                        } else {
                                            // imgPath = this.img2;
                                        }
                                    }
                                    const ckeck = judgeData[i].checkId !== "" && judgeData[i].checkId !== undefined && judgeData[i].checkId !== null ? judgeData[i].checkId : "";
                                    const judge = {
                                        remark: judgeData[i].remark,
                                        ifJudge: true,
                                        questionResult: judgeData[i].questionResult,
                                        subject: judgeData[i].questionInfo,
                                        checked: ckeck,
                                        questionId: judgeData[i].questionId,
                                        imgPath: imgPath
                                    };
                                    const questionDetailList = judgeData[i]["questionDetailList"];
                                    for (let j = 0; j < questionDetailList.length; j++) {
                                        const questionDetail = questionDetailList[j];
                                        if (questionDetail.correctOption === "1") {
                                            judge["answer"] = questionDetail.questionDetailId;
                                        }
                                    }
                                    judge["questionDetailList"] = questionDetailList;
                                    this.judgeData.push(judge);
                                }
                            }
                            if (this.judgeData.length === 0) {
                                this.judgeShow = false;
                            }
                        }
                        this.listLoading = false;
                    }).catch(e => {
                        this.listLoading = false;
                        this.$Message.error("获取试题失败");
                    });
            },
            submit(){
                this.$Modal.confirm({
                    title: '交卷',
                    content: '<p>确定提交当前试卷么！</p>',
                    okText: '确认',
                    onOk: () => {
                        this.listLoading = true;
                        let score = 0;
                        const questionData = [];
                        const data = {
                            paperResultId: this.paperResultId,
                            examStartTime: new Date(this.beginTime), // 考试开始时间
                            examEndTime: new Date(), // 考试结束时间
                            examTime: "" // 考试用时（分钟）
                        };
                        // 用时
                        const minutes = data.examEndTime.getTime() - data.examStartTime.getTime();
                        data.examTime = parseInt(minutes / (1000 * 60));
                        const second = (minutes % (1000 * 60)) / 1000;
                        if (second > 0 && data.examTime < this.examDuration) {
                            data.examTime = data.examTime + 1;
                        }
                        // 单选
                        for (let i = 0; i < this.radioData.length; i++) {
                            let result = 0;
                            if (this.radioData[i].answer !== this.radioData[i].checked) {
                                result = 1;
                            } else {
                                score += this.paper.paperRadioNum;
                            }
                            questionData.push({
                                questionDetailId: this.radioData[i].checked,
                                questionId: this.radioData[i].questionId,
                                questionResult: result
                            });
                        }
                        // 多选
                        for (let i = 0; i < this.checkboxData.length; i++) {
                            let questionDetailId = "";
                            let result = 0;
                            if (this.checkboxData[i].answer.length === this.checkboxData[i].checked.length) {
                                let count = true;
                                for (let j = 0; j < this.checkboxData[i].checked.length; j++) {
                                    if (!this.checkboxData[i].answer.includes(this.checkboxData[i].checked[j])) {
                                        count = false;
                                        result = 1;
                                    }
                                    questionDetailId += this.checkboxData[i].checked[j] + ",";
                                }
                                if (count) {
                                    score += this.paper.paperCheckboxNum;
                                }
                            } else {
                                result = 1;
                                for (let j = 0; j < this.checkboxData[i].checked.length; j++) {
                                    questionDetailId += this.checkboxData[i].checked[j] + ",";
                                }
                            }
                            questionData.push({
                                questionDetailId: questionDetailId.substring(0, questionDetailId.length - 1),
                                questionId: this.checkboxData[i].questionId,
                                questionResult: result
                            });
                        }
                        // 判断
                        for (let i = 0; i < this.judgeData.length; i++) {
                            let result = 0;
                            if (this.judgeData[i].answer !== this.judgeData[i].checked) {
                                result = 1;
                            } else {
                                score += this.paper.paperJudgeNum;
                            }
                            questionData.push({
                                questionDetailId: this.judgeData[i].checked,
                                questionId: this.judgeData[i].questionId,
                                questionResult: result
                            });
                        }
                        data.paperDetailList = questionData;
                        data.paperResult = score; // 答题分数
                        this.$http.post(Api.paper+'/savePaperResult', data).then(res => {
                            if (res.data.status === 200) {
                                this.ansewrDetail = true;
                                this.paperResult = score;
                            } else {
                                this.$Message.error(res.data.msg);
                                this.$emit("closeAnswer", false);
                            }
                            this.listLoading = false;
                        }).catch(e => {
                            this.listLoading = false;
                            this.$Message.error("提交失败");
                        });
                    },
                    cancelText: '取消'
                });
            },
            // 时间到自动提交试卷
            autoSubmit() {
                this.listLoading = true;
                let score = 0;
                const questionData = [];
                const data = {
                    paperResultId: this.paperResultId,
                    examStartTime: new Date(this.beginTime), // 考试开始时间
                    examEndTime: new Date(), // 考试结束时间
                    examTime: "" // 考试用时（分钟）
                };
                // 用时
                const minutes = data.examEndTime.getTime() - data.examStartTime.getTime();
                data.examTime = parseInt(minutes / (1000 * 60));
                const second = (minutes % (1000 * 60)) / 1000;
                if (second > 0 && data.examTime < this.examDuration) {
                    data.examTime = data.examTime + 1;
                }
                // 单选
                for (let i = 0; i < this.radioData.length; i++) {
                    let result = 0;
                    if (this.radioData[i].answer !== this.radioData[i].checked) {
                        result = 1;
                    } else {
                        score += this.paper.paperRadioNum;
                    }
                    questionData.push({
                        questionDetailId: this.radioData[i].checked,
                        questionId: this.radioData[i].questionId,
                        questionResult: result
                    });
                }
                // 多选
                for (let i = 0; i < this.checkboxData.length; i++) {
                    let questionDetailId = "";
                    let result = 0;
                    if (this.checkboxData[i].answer.length === this.checkboxData[i].checked.length) {
                        let count = true;
                        for (let j = 0; j < this.checkboxData[i].checked.length; j++) {
                            if (!this.checkboxData[i].answer.includes(this.checkboxData[i].checked[j])) {
                                count = false;
                                result = 1;
                            }
                            questionDetailId += this.checkboxData[i].checked[j] + ",";
                        }
                        if (count) {
                            score += this.paper.paperCheckboxNum;
                        }
                    } else {
                        result = 1;
                        for (let j = 0; j < this.checkboxData[i].checked.length; j++) {
                            questionDetailId += this.checkboxData[i].checked[j] + ",";
                        }
                    }
                    questionData.push({
                        questionDetailId: questionDetailId.substring(0, questionDetailId.length - 1),
                        questionId: this.checkboxData[i].questionId,
                        questionResult: result
                    });
                }
                // 判断
                for (let i = 0; i < this.judgeData.length; i++) {
                    let result = 0;
                    if (this.judgeData[i].answer !== this.judgeData[i].checked) {
                        result = 1;
                    } else {
                        score += this.paper.paperJudgeNum;
                    }
                    questionData.push({
                        questionDetailId: this.judgeData[i].checked,
                        questionId: this.judgeData[i].questionId,
                        questionResult: result
                    });
                }
                data.paperDetailList = questionData;
                data.paperResult = score; // 答题分数
                this.$http.post(Api.paper+'/savePaperResult', data).then(res => {
                    if (res.data.status === 200) {
                        this.ansewrDetail = true;
                        this.paperResult = score;
                    } else {
                        this.$Message.error(res.data.msg);
                        this.$emit("closeAnswer", false);
                    }
                    this.listLoading = false;
                }).catch(e => {
                    this.listLoading = false;
                    this.$Message.error("自动提交失败");
                });
            },
            goback(){
                this.$emit("closeAnswer", false);
            },

        }
    }
</script>

<style scoped lang="less">
    .problem_item {
        font-size: 16px;
        margin-bottom: 6px;
        width: 100%;
    }
    .checkbox_item {
        margin: 8px 0;
    }
</style>
